package com.prik.command.remotecontrol;

import com.prik.command.Command;
import com.prik.command.products.*;
import com.prik.command.commands.*;

/**
 * 遥控器测试
 **/
public class RemoteControlTest {
    public static void main(String[] args) {
        RemoteControl control = new RemoteControl();

        Light bedroomLight = new Light("bedroom");
        Light kitchenLight = new Light("kitchen");
        Stereo stereo = new Stereo();
        ElectricFan livingRoomFan = new ElectricFan("livingRoom");

        LightOnCommand bedroomLightOnCommand = new LightOnCommand(bedroomLight);
        LightOffCommand bedroomLightOffCommand = new LightOffCommand(bedroomLight);

        LightOnCommand kitchenLightOnCommand = new LightOnCommand(kitchenLight);
        LightOffCommand kitchenLightOffCommand = new LightOffCommand(kitchenLight);

        StereoOnWithCdCommand stereoOnWithCdCommand = new StereoOnWithCdCommand(stereo);
        StereoOffWithCdCommand stereoOffWithCdCommand = new StereoOffWithCdCommand(stereo);

        ElectricFanSpeedHighCommand livingRoomFanSpeedHighCommand = new ElectricFanSpeedHighCommand(livingRoomFan);
        ElectricFanOffCommand livingRoomFanOffCommand = new ElectricFanOffCommand(livingRoomFan);


        control.setCommand(0, bedroomLightOnCommand, bedroomLightOffCommand);
        control.setCommand(1, kitchenLightOnCommand, kitchenLightOffCommand);
        control.setCommand(2, stereoOnWithCdCommand, stereoOffWithCdCommand);

        control.setCommand(3, livingRoomFanSpeedHighCommand, livingRoomFanOffCommand);

        System.out.println(control.toString());

        // control.pushOnButton(1);
        // control.pushUndoButton();
        // control.pushOnButton(2);
        // control.pushOffButton(2);
        // control.pushUndoButton();

        // control.pushOnButton(3);
        // control.pushOffButton(3);
        // control.pushUndoButton();


        // 宏命令测试
        Command[] turnOnAllLightsArr = {bedroomLightOnCommand, kitchenLightOnCommand};
        Command[] turnOffAllLightsArr = {bedroomLightOffCommand, kitchenLightOffCommand};

        MacroCommand turnOnAllLights = new MacroCommand(turnOnAllLightsArr);
        MacroCommand turnOffAllLights = new MacroCommand(turnOffAllLightsArr);

        control.setCommand(4, turnOnAllLights, turnOffAllLights);


        control.pushOnButton(4);
        control.pushOffButton(4);
        control.pushUndoButton();
    }
}